﻿var _baseModel = {
    openid: GetRequest("openid"),
    did: GetRequest("did"),
    gatename: decodeURI(GetRequest("gatename")),
    userimage: "http://1.shhomer.sinaapp.com/output/GetImg.php?openid=" + GetRequest("openid") + "&did=" + GetRequest("did")
}
var _baseDataTime = {
    hours: ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"],
    minute: ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"]
}
function _scrollSame() { $('.divbox').scroll(function () { /**$('.divbox').scrollTop($(this).scrollTop());**/$('.divbox').scrollLeft($(this).scrollLeft()); }); }
$(".headinfobox a").each(function () { this.href = this.href + "?openid=" + _baseModel.openid + "&did=" + _baseModel.did + "&gatename=" + _baseModel.gatename; });
$(".columnpic").html("<img src='"+_baseModel.userimage+"' />");
var _baseformat = {
    formatTime: function (date) {
        if (date == null || date == undefined) { return; }
        date = date.replace(/-/g, "/")
        date = new Date(date);
        var hours = date.getHours();
        hours = hours < 10 ? "0" + hours : hours;
        var Minutes = date.getMinutes();
        Minutes = Minutes < 10 ? "0" + Minutes : Minutes;
        return hours + ":" + Minutes;
    },
    formatDate: function (date) {
        if (date == null || date == undefined) { return; }
        date = date.replace(/-/g, "/")
        date = new Date(date);
        var _month = date.getMonth() + 1;
        _month = _month < 10 ? "0" + _month : _month;
        var _date = date.getDate();
        _date = _date < 10 ? "0" + _date : _date;
        return _month + "/" + _date + "/" + date.getFullYear();
    },
    formatDateTime: function (date) {
        if (date == null || date == undefined) { return; }
        date = date.replace(/-/g, "/")
        date = new Date(date);
        var _month = date.getMonth() + 1;
        _month = _month < 10 ? "0" + _month : _month;
        var _date = date.getDate();
        _date = _date < 10 ? "0" + _date : _date;
        var hours = date.getHours();
        hours = hours < 10 ? "0" + hours : hours;
        var Minutes = date.getMinutes();
        Minutes = Minutes < 10 ? "0" + Minutes : Minutes;
        return date.getFullYear() + "/" + _month + "/" + _date + " " + hours + ":" + Minutes;
    }
}
var locationHREF = window.location.href;
if (locationHREF.indexOf("openid=") < 0 || locationHREF.indexOf("did=") < 0) {
    var methods = new GetDataJSON();
    methods.GetGates("o3eaus6PSrb7iEjqZ__Mtq_kuNsU", skip);
    function skip(result) {
        if (checkStatus(result.Status)) {
            window.location = "http://www.laoyou1.me/chart/index.php?openid=o3eaus6PSrb7iEjqZ__Mtq_kuNsU&did=" + result.Data[0][0] + "&gatename=" + result.Data[0][1];
        } else {
            alert(result.Message);
        }
    }
}
//$(".tabbox a").each(function () { this.href = this.href + "?openid=" + _baseModel.openid + "&did=" + _baseModel.did + "&gatename=" + _baseModel.gatename; });
function layerShow(id) {
    layer.open({
        type: 1,
        area: '95%',
        title: false,
        closeBtn: 0,
        skin: '',
        content: $("#" + id)
    });
}
function GetRequest(val) {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for (var i = 0; i < strs.length; i++) {
            theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
        }
    }
    return val ? theRequest[val] : theRequest;
}
function GetDateStr(thisdate, AddDayCount) {
    var dd = (thisdate != null) ? dd = new Date(thisdate) : new Date();
    dd.setDate(dd.getDate() + AddDayCount);//获取AddDayCount天后的日期
    var y = dd.getFullYear();
    var m = dd.getMonth() + 1;//获取当前月份的日期
    var d = dd.getDate();
    return (y + "/" + m + "/" + d);
}
function getChartTime(thisdate) {
    var days = [];
    var dayscale = [];
    var datearray = [];
    for (var i = 7; i > 0; i--) { days.push(GetDateStr(thisdate, -i)); }
    datearray.starttime = days[0];
    datearray.endtime = days[days.length - 1];
    return { days: days, datearray: datearray };
}
